/* 默认全局数据 */

let globalData = {
  authCode: '',
  bclicked: false,
  isLogin: false,
  userInfo: {
    userId: '',
    id: '',
    tenantId: '',
    userName: '',
    role: '',
    roleDic: '',
    score: 0,
    ranking: 0,
    level: 0,
    image: ''
  },
  serverTime: ''
}

let app_settings = {
  onLaunch() {
  },

  onShow() {
    console.log(123)
  },

  onHide() {

  },

  /**
   * 设置默认全局数据
   */
  setDefGlobalData() {
    app_settings.globalData = globalData
  },

  /**
   * 业务方调用方法
   */
  methods: {
    // 检查是否授权登录
    checkLogin(cb) {
      if (app_settings.globalData.isLogin) {
        cb && cb(app_settings.globalData.isLogin)
      }
    },

    // 防止重复点击
    enableButtonClicked: function () {
      if (app_settings.globalData.bclicked) {
        return false
      } else {
        app_settings.globalData.bclicked = true

        setTimeout(function () {
          app_settings.globalData.bclicked = false
        }, 500)
        return true
      }
    }
  },

  /**
   * 全局数据
   */
  globalData: globalData
}

App(app_settings);